package com.Tradition.service;

import com.Tradition.mapper.BadMapper;
import com.Tradition.model.Bad;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * BadService
 *
 * @author 朱笑
 * @date 2018-06-25 15:35
 */
@Service
public class BadService {
    @Autowired
    BadMapper badMapper;
    public int insertBad(int areaid,String annotation,String content,int userid){
        Bad bad=new Bad();
        bad.setAreaid(areaid);
        bad.setAnnotation(annotation);
        bad.setContent(content);
        bad.setCreatetime(new Date());
        bad.setUserid(userid);
        bad.setStatus(0);
        bad.setDelete(0);
        return badMapper.insert(bad);
    }
    public Bad queryBadById(int badId){
        return badMapper.selectByPrimaryKey(badId);
    }
    public List<Bad> queryBadPage(int pageNum,int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<Bad> badPage = badMapper.findBadPage();
        return badPage;
    }
}
